var util = require('../../utils/util.js');
var app = getApp();
Page({
  data: {
    tc: 0,
    page: 1,
    limit: 10,
    topicType: 8, //默认是 近况（相册）
    albumid: '', //子分类
    postuid: '',
    data: [],
    imgDomain: app.globalData.imgDomain,
    hasMore: true,
    hasLoadding: false,
    noData: false,

    wz_item_img_w_1: 300,
    wz_item_img_w_2: 300,
    wz_item_img_w_3: 300
  },

  onLoad: function(options) {

    var that = this;
    var tc = app.get_tc();
    that.setData({
      tc: tc,
      orgname: ''
    })
    if (util.orgid == '14439') {
      that.setData({
        orgname: tc == 1 ? '佛山車金融' : '佛山车金融'
      })
    }
    if (util.orgid == '15848') {
      that.setData({
        orgname: tc == 1 ? '廣東車險匯' : '广东车险汇'
      })
    }

    if (util.orgid == '12545') {
      that.setData({
        orgname: tc == 1 ? 'Sky21 點餐系統' : 'Sky21 点餐系统'
      })
    }
    if (util.orgid == '17784') {
      that.setData({
        orgname: tc == 1 ? '八戒報名' : '八戒报名'
      })
    }
    if (util.orgid == '16708') {
      that.setData({
        orgname: tc == 1 ? 'JSK著數皇' : 'JSK着数皇'
      })
    }
    if (util.orgid == '18681') {
      that.setData({
        orgname: tc == 1 ? '澳卡鮮奶' : '澳卡鲜奶'
      })
    }
    if (util.orgid == '18535') {
      that.setData({
        orgname: tc == 1 ? '家家公寓' : '家家公寓'
      })
    }
    var titlename = tc == 1 ? '微信授權登錄' : '微信授权登录';
    //console.log(util.orgname);

    wx.setNavigationBarTitle({
      // title: options.title,
      title: titlename,
    })
    //获取颜色配置
    app.getColorSetData(function(color) {
      that.setData({
        colorSet: color
      })
      that.resetNavColor();
    });

  },


  goAtherPage: function(e) {
    var url = e.currentTarget.dataset.link;
    wx.navigateTo({
      url: url
    })
  },
  onReady: function() {
    // 页面渲染完成
  },
  onShow: function() {
    // 页面显示
  },
  onHide: function() {
    // 页面隐藏
  },
  onUnload: function() {
    // 页面关闭
  },

  onGotUserInfo: function(e) {
    console.log("授权结果：", e);
    if (e.detail.encryptedData) { //用户已授权，去获取授权用户信息
      wx.showLoading({
        title: 'loading...',
        mask: true
      })
      app.AuthUserInfo(function(res) {
        console.log("mine login:", res);
        wx.navigateBack({
          delta: 1
        });
        wx.hideLoading();
      }, true);
    }
  },

  resetNavColor: function() {
    var bg_color = '#d8202d';
    var fg_color = '#ffffff';

    if (this.data.colorSet) {
      var colorJO = this.data.colorSet;
      bg_color = colorJO.titlebg;
      fg_color = colorJO.titlefont;
    }
    wx.setNavigationBarColor({
      frontColor: fg_color,
      backgroundColor: bg_color
    });
    this.setData({
      backgroundColor: bg_color
    })
  },
})